package com.webapp.model;


import com.webapp.constants.RetCode;

/**
 * @Author: Jimmy Li
 * @Mail: jimmy.c.li@cn.pwc.com
 * @Date: 27 Mar 2020
 * @Description: 
 */


public class RetResponse {

	private final static String SUCCESS = "成功";

	private final static String FAIL = "失败";

	public static <T> RetResult<T> makeOKRsp() {
		return new RetResult<T>().setCode(RetCode.SUCCESS_CODE).setMsg(SUCCESS);
	}

	public static <T> RetResult<T> makeOKRsp(T data) {
		return new RetResult<T>().setCode(RetCode.SUCCESS_CODE).setMsg(SUCCESS).setData(data);
	}

	public static <T> RetResult<T> makeErrRsp() {
		return new RetResult<T>().setCode(RetCode.FAIL_CODE).setMsg(FAIL);
	}

	public static <T> RetResult<T> makeErrRsp(T data) {
		return new RetResult<T>().setCode(RetCode.FAIL_CODE).setMsg(FAIL).setData(data);
	}

	public static <T> RetResult<T> makeRsp(int code, String msg) {
		return new RetResult<T>().setCode(code).setMsg(msg);
	}

	public static <T> RetResult<T> makeRsp(int code, String msg, T data) {
		return new RetResult<T>().setCode(code).setMsg(msg).setData(data);
	}
}
